package com.niiwoo.civet.mobile.service.bill.detail;

import com.alibaba.fastjson.JSON;
import com.niiwoo.civet.account.dto.response.NiiwooBillRespDTO;
import com.niiwoo.civet.account.dto.response.UserBillBaseResponseDTO;
import com.niiwoo.civet.mobile.vo.response.bill.JumpTypeEnum;
import com.niiwoo.civet.mobile.vo.response.bill.UserBillDetailResponse;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 还款账单说情
 * Created by Yijian on 2018/11/9.
 */
@Service
public class RepaymentBillDetailStrategyImpl implements BillDetailStrategy {

    @Value("${h5-borrow-detail-url}")
    private String h5BorrowDetailUrl;

    @Override
    public String build(UserBillBaseResponseDTO userBillBase, List<NiiwooBillRespDTO> userBillFlowList, UserBillDetailResponse response) {

        UserBillDetailResponse.SpecialItem specialItem = response.new SpecialItem();
        specialItem.setName("借款详情");
        specialItem.setContent("借款-" + userBillBase.getTotalPeriods() + "期");
        specialItem.setIsNeedJump(Boolean.TRUE);
        specialItem.setJumpType(JumpTypeEnum.BORROW_DETAIL.getCode());
        specialItem.setJumpParamOne(userBillBase.getProjectId().toString());//标的id
        specialItem.setJumpParamTwo(this.h5BorrowDetailUrl + userBillBase.getProjectId());
        response.getSpecialItems().add(specialItem);

        return JSON.toJSONString(response);
    }
}
